My Profile_


In App

Introduction

This documentation contains the instructions for integrating Google Pay™ as an in-app purchase option using the Moneris Gateway Google API for Canada. It contains specifications for transaction requests and responses.

Please ensure to also review the link to Overview section for Google Pay™ section to use this SDK.

In order to integrate your Google Pay™ payment solution with Moneris, there are a few basic tasks you need to do:
For Google Pay™ In-App, follow these steps:

  1. Build a demo application for Google Pay™ In-App SDK
  2. Customize your demo app's code to work with the Moneris Gateway
  3. Compile and run your application
  4. Verify the transactions using the Merchant Resource Center.

For additional information on Google Pay™ development, consult Google's developer site:
In-App (Android): https://developers.google.com/pay/api/android/

Building a Google Pay™ Demo App

A demo checkout application is required as part of the integration process for Google Pay™. Google provides code for a Google Pay™ demo application to make it easy.
To build a Google Pay™ demo application:

  1. Go to Google's Google Pay™ quick start page on Github at https://github.com/googlepay/android-quickstart
  2. Git clone the Android-Quickstart library to your computer
  3. Unzip the project library
  4. Open Android Studio and import this project as a gradle project
  5. Sync the gradle

Integrating Your Demo App with Moneris Gateway

To begin testing your integration, you need to modify code in your Google Pay™ demo application project to enable it to communicate with the Moneris Gateway.
To integrate your demo app with the Moneris Gateway, do the following:

  1. In the file Constants.java,
    a. set the GATEWAY_TOKENIZATION_NAME to "moneris"
    b. change exampleGatewayMerchantId to your testing Store ID
  2. In the file CheckoutActivity.java
    a. in the section LOAD_PAYMENT_DATA_REQUEST_CODE of onActivityResult, replace this code
    
    PaymentData paymentData = PaymentData.getFromIntent(data);
    handlePaymentSuccess(paymentData);
    with the following field after the PaymentData is received:
    PaymentData paymentData = PaymentData.getFromIntent(data);
    try {
    com.moneris.googlepay.api.Recur recurInfo = new Recur.Builder()
    .setRecurAmount("1.00") // Amount to be sent when managed recur transaction is triggered
    .setStartDate("2018/09/01") // First day the recurring starts
    .setStartNow("false") // true to charge the transaction amount now or false to register the sequence
    .setNumRecurs("5") // Number of recurs
    .setPeriod("day") // The period for the recur, can be "day", "week", "month", or "eom"
    .build();
    com.moneris.googlepay.api.Purchase purchase = (com.moneris.googlepay.api.Purchase) new
    com.moneris.googlepay.api.Request.Builder()
    .setTransactionType(Constants.TransactionCode.PURCHASE)
    // Mandatory
    .setOrderId("GooglePayTest-"+new Date().getTime()) // Mandatory, must be unique for all transactions
    .setPaymentData(paymentData) // Mandatory, data returned from Google
    .setAmount(PaymentsUtil.microsToString(mBikeItem.-
    getPriceMicros()+mShippingCost)) // Transaction amount processed
    .setRecur(recurInfo) // Optional, only apply to recurring registration
    .setCustId("Customer 1") // Optional, to display Customer Id for transaction
    .build();
    // Transaction transport structure
    com.moneris.googlepay.api.MonerisHttpsPost monerisHttpsPost = new com.-
    moneris.googlepay.api.MonerisHttpsPost.Builder()
    .setStoreId(com.-
    google.android.gms.samples.wallet.Constants.GATEWAY_TOKENIZATION_PARAMETERS.get(0).second)
    // Mandatory, should be securely stored.
    .setApiToken
    ("spedguy") // Mandatory, should be securely stored.
    .setRequest(purchase)
    Page 6 of 22 October 2018
    1 Getting Started With Google Pay™
    // Mandatory from line above
    .setTestMode(true) // Optional, default is testMode false;
    .build();
    // Send transaction
    com.moneris.googlepay.api.Response resp = monerisHttpsPost.send();
    // Simple test to check if transaction is approved.
    int numRespCode = Integer.parseInt(resp.getResponseCode());
    if ( numRespCode < 50 )
    {
    // Approved complete the transaction.
    handlePaymentSuccess(paymentData);
    } else
    {
    // Declined transaction
    handleError(numRespCode);
    }
    } catch (
    Exception ex)
    {
    Log.e("ERROR", "Failed to send transaction with error: "+ex.getMessage());
    // send -1 for a catch all error
    handleError(-1);
    }
    

    b. in the code snippet above, change the exampleApiToken value to your testing API token